<?php
$data = "";
$zipcodes_file = file_get_contents("zipcodes.csv");
$cities = explode("\n",$zipcodes_file);
foreach ($cities as $city_line) {
	list($zipcode,$city) = explode(";",$city_line);
	$city = strtolower($city);
	$city = ucfirst($city);
	if (!empty($city)) {
		$inner_sql = "SELECT id FROM cities WHERE name='$city'";
		$data .= "INSERT INTO zip_codes (zipcode,city_id) VALUES ('$zipcode',($inner_sql));\n";
	}
}
file_put_contents("zipcodes.sql",$data);
print "\n";
?>
